<template>
	<view class="tab-box">
		<view v-if="!tfclick">
			<view class="top-comm">
				<view class="title-box">
					<view>
						vae
					</view>
				</view>
				<view class="comm-butt">
					<view>
						<view class="icon-box" @click="but_inpt()">
							<uni-icons type="search" color="#fff" size="55rpx" />
						</view>
					</view> 
				</view>
			</view>
		</view>
		<view v-else>
			<view class="top-comm">
				<view class="inp-box">
					<input class="inputSearch" type="text" confirm-type="search" @input="onInput" placeholder="搜索"/>
					<view class="right-box" @click="input_sub()">
						<view class="icon-butt">
							<uni-icons type="search" color="#000000" size="20" />
						</view>
					</view>
				</view>	
				<view class="clear-box">
					<view style="height: 30px;
					width: 35px;" @click="but_clear()">
						<view style="font-size: 25rpx;">取消</view>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
	    components:{
	    },
		data() {
			return {
				tfclick:false,
				inText:null,
			}
		},
		methods: {
			but_inpt(){
				this.tfclick=true;
			},
			but_clear(){
				this.tfclick=false;
			},
			input_sub(){
				this.tfclick=false;
				this.submitCent(this.inText);
			},
			onInput(e){
				this.inText=e.target.value;
			},
			submitCent(e){
				uni.showToast({
					title: '你搜索了'+ e,
					icon: 'none',    //如果要纯文本，不要icon，将值设为'none'
					duration: 2000    //持续时间为 2秒
				})  

			}
		}
	}
	
</script>

<style>
	.tab-box{
		height: 6vh;
		width: 100%;
	}
	.top-comm{
		height: 6vh;
		display: flex;
		display: -webkit-flex;
		justify-content: flex-end;
		align-items: center;
	}
	.clear-box{
		 width: 10%;
		 display: -webkit-flex;
		 display: flex;
		 justify-content: space-evenly;
	}
	.tab-box{
		background-color: #289b7E;
		color: #fff;
	}
	.inputSearch{
		height: 4vh;
		float: left;
		background: rgba(255, 255, 255, 0.5);
		border-top-left-radius: 2vh;
		border-bottom-left-radius: 2vh;
		-webkit-flex: 1;
		flex: 1;
	}
	button{
		height: 30px;
		width: 30px;
		margin: 7px 5px 0 -35px;
		position: absolute;
		float: right;
		background: rgba(0, 0, 0, 0);
		border: none;
	}
	
	.icon-box{
		height: 30px;
		line-height: 30px;
	}
	.tab-box{
		font-weight: 700;
		font-size: 16px;
		line-height: 30px;
		text-align: center;
		overflow: hidden;
		white-space: nowrap;
		text-overflow: ellipsis;
	}
	.title-box{
		display: inline-block;
		width: 80%;
		height: 5vh;
		line-height: 5vh;
	}
    .comm-butt{
		float: right;
		width: 10%;
	}
	.inp-box{
		width: 80%;
		display: -webkit-flex;
		display: flex;
	}
	.right-box{
		float: right;
		height: 4vh;
		width: 30px;
		background: rgba(255, 255, 255, 0.5);
		border-top-right-radius: 2vh;
		border-bottom-right-radius: 2vh;
		
		border-left: 1px solid #b9b9b9;
	}
	.icon-butt{
		margin: 0 6px;
		line-height: 22.4px;
	}
</style>